package com.juc.countdownlatch.countdownlatch5;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class MyService {
  /**
   * await(long timeout ,timeUnit unit) 的作用是使线程在指定的最大单位时间内
   * 进入waiting 状态，如果超过时间则自动唤醒，程序继续向下执行。
   * 参数timeout 是等待时间 unit是时间的单位
   */
	
	private CountDownLatch count = new CountDownLatch(1);
	
	public  void testMethod() {
		try {
			System.out.println(Thread.currentThread().getName() + " 准备 " + System.currentTimeMillis());
			count.await(3, TimeUnit.SECONDS);
			System.out.println(Thread.currentThread().getName() + " 结束 " + System.currentTimeMillis());

		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
	}
}
